package edu.gatech.cs4235.group3.action;


/**
 * /**
 * This OnePadDecryptAction decrypts files specified with the One-Time pad files.
 * 
 * 
 * @author Jeffrey Starker
 *
 */
public class OnePadDecryptAction extends OnePadCryptAction {
	
	/**
	 * Creates a OnePadDecryptAction with the given arguments.
	 *
	 * @param decryptFiles A comma-separated list of files to decrypt.
	 * @param padFiles A comma-separated list of pad files.
	 */
	public OnePadDecryptAction(final String decryptFiles, final String padFiles) {
		super(decryptFiles, padFiles);
	}

	/**
	 * Returns the crypto type of this action: "decrypt".
	 * 
	 * @return "decrypt"
	 */
	@Override
	public String getCryptType() {
		return "decrypt";
	}

	/**
	 * This method decrypts the files using the one-time pads.
	 * 
	 */
	@Override
	protected char crypt(final char cryptValue, final char padValue) {
		
		int cryptValueInt = cryptValue - 32;
		int padValueInt = padValue - 32;
		
		// Perform decrypt.
		return (char) (((cryptValueInt - padValueInt) % 95) + 32);
	}

}
